package com.springSpringMVC;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MysqlUtil {
    static {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public Connection getConnetion(){
        try {
            return DriverManager.getConnection("jdbc:mysql:localhost:3306/spring-springMVC","root","1234");
        } catch (SQLException e) {

            e.printStackTrace();
        }
        System.out.println("数据库连接错误");
        return null;
    }
}
